package cn.stylefeng.guns.modular.biz.controller;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.guns.modular.biz.entity.PmPowerplantProConBom;
import cn.stylefeng.guns.modular.biz.pojo.request.PmPowerplantProConBomRequest;
import cn.stylefeng.guns.modular.biz.pojo.response.PmPowerplantProConBomGroupByDateVo;
import cn.stylefeng.guns.modular.biz.service.PmPowerplantProConBomService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * MES投煤量数据控制器
 *
 * @author 张朋飞
 * @since 2024/10/08 17:03
 */
@RestController
@ApiResource(name = "MES投煤量数据")
public class PmPowerplantProConBomController {

    @Resource
    private PmPowerplantProConBomService pmPowerplantProConBomService;

    /**
     * 添加MES投煤量数据
     *
     * @author 张朋飞
     * @since 2024/10/08 17:03
     */
    @PostResource(name = "添加MES投煤量数据", path = "/pmPowerplantProConBom/add")
    public ResponseData<PmPowerplantProConBom> add(@RequestBody @Validated(PmPowerplantProConBomRequest.add.class) PmPowerplantProConBomRequest pmPowerplantProConBomRequest) {
        pmPowerplantProConBomService.add(pmPowerplantProConBomRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 删除MES投煤量数据
     *
     * @author 张朋飞
     * @since 2024/10/08 17:03
     */
    @PostResource(name = "删除MES投煤量数据", path = "/pmPowerplantProConBom/delete")
    public ResponseData<?> delete(@RequestBody @Validated(PmPowerplantProConBomRequest.delete.class) PmPowerplantProConBomRequest pmPowerplantProConBomRequest) {
        pmPowerplantProConBomService.del(pmPowerplantProConBomRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 批量删除MES投煤量数据
     *
     * @author 张朋飞
     * @since 2024/10/08 17:03
     */
    @PostResource(name = "批量删除MES投煤量数据", path = "/pmPowerplantProConBom/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) PmPowerplantProConBomRequest pmPowerplantProConBomRequest) {
        pmPowerplantProConBomService.batchDelete(pmPowerplantProConBomRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑MES投煤量数据
     *
     * @author 张朋飞
     * @since 2024/10/08 17:03
     */
    @PostResource(name = "编辑MES投煤量数据", path = "/pmPowerplantProConBom/edit")
    public ResponseData<?> edit(@RequestBody @Validated(PmPowerplantProConBomRequest.edit.class) PmPowerplantProConBomRequest pmPowerplantProConBomRequest) {
        pmPowerplantProConBomService.edit(pmPowerplantProConBomRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 查看MES投煤量数据详情
     *
     * @author 张朋飞
     * @since 2024/10/08 17:03
     */
    @GetResource(name = "查看MES投煤量数据详情", path = "/pmPowerplantProConBom/detail")
    public ResponseData<PmPowerplantProConBom> detail(@Validated(PmPowerplantProConBomRequest.detail.class) PmPowerplantProConBomRequest pmPowerplantProConBomRequest) {
        return new SuccessResponseData<>(pmPowerplantProConBomService.detail(pmPowerplantProConBomRequest));
    }

    /**
     * 获取MES投煤量数据列表
     *
     * @author 张朋飞
     * @since 2024/10/08 17:03
     */
    @GetResource(name = "获取MES投煤量数据列表", path = "/pmPowerplantProConBom/list")
    public ResponseData<List<PmPowerplantProConBom>> list(PmPowerplantProConBomRequest pmPowerplantProConBomRequest) {
        return new SuccessResponseData<>(pmPowerplantProConBomService.findList(pmPowerplantProConBomRequest));
    }

    /**
     * 获取MES投煤量数据列表
     *
     * @author 张朋飞
     * @since 2024/10/08 17:03
     */
    @GetResource(name = "获取MES投煤量数据列表 分组日期", path = "/pmPowerplantProConBom/listByDate")
    public ResponseData<PmPowerplantProConBomGroupByDateVo> listGroupDate(PmPowerplantProConBomRequest pmPowerplantProConBomRequest) {
        PmPowerplantProConBomGroupByDateVo pmPowerplantProConBomGroupByDateVo = new PmPowerplantProConBomGroupByDateVo();
        if(ObjectUtil.isAllNotEmpty(pmPowerplantProConBomRequest.getGatherDate())){
            pmPowerplantProConBomGroupByDateVo= pmPowerplantProConBomService.listGroupDate(pmPowerplantProConBomRequest.getGatherDate());
        }
        return new SuccessResponseData<>(pmPowerplantProConBomGroupByDateVo);
    }

    /**
     * 获取MES投煤量数据列表（带分页）
     *
     * @author 张朋飞
     * @since 2024/10/08 17:03
     */
    @GetResource(name = "获取MES投煤量数据列表（带分页）", path = "/pmPowerplantProConBom/page")
    public ResponseData<PageResult<PmPowerplantProConBom>> page(PmPowerplantProConBomRequest pmPowerplantProConBomRequest) {
        return new SuccessResponseData<>(pmPowerplantProConBomService.findPage(pmPowerplantProConBomRequest));
    }

}
